//
//  NovelAlbumTableViewCell.m
//  A_program
//
//  Created by dlios on 15-5-23.
//  Copyright (c) 2015年 BayMax. All rights reserved.
//

#import "NovelAlbumTableViewCell.h"
#import "NovelAlbumListModel.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <SDWebImage/UIImage+MultiFormat.h>

@implementation NovelAlbumTableViewCell
- (void)dealloc
{
    [self.albumListImageView release];
    [self.albumDownLoad release];
    [self.albumListLable release];
    [self.albumFristListLable release];
    [self.fristAlbumSmallImage release];
    [self.fristAlbumSmallLable release];
    [self.secondAlbumSmallImage release];
    [self.secondAlbumSmallLable release];
    [self.thirdAlbumSmallImage release];
    [self.thirdAlbumSmallLable release];
    [self.myView release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createAlbumListCell];
        [self setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:0.9]];
    }
    return self;
}
- (void)createAlbumListCell{
    self.myView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height/6 - 10)];
    [self.myView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:self.myView];
    [self.myView release];

    self.albumListImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width/5 - 20, [UIScreen mainScreen].bounds.size.width/5 - 20)];
    [self.myView addSubview:self.albumListImageView];
    self.albumListImageView.layer.cornerRadius = ([UIScreen mainScreen].bounds.size.width/5 - 20)/2;
    self.albumListImageView.layer.masksToBounds = YES;

    [self.albumListImageView release];
    
    self.albumListLable = [[UILabel alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5, 10, [UIScreen mainScreen].bounds.size.width *3 / 5, 20)];
    [self.myView addSubview:self.albumListLable];
    [self.albumListLable release];
    
    self.albumFristListLable = [[UILabel alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5 + 5, 35, 100, 20)];
    self.albumFristListLable.font = [UIFont systemFontOfSize:13];
    [self.myView addSubview:self.albumFristListLable];

    [self.albumFristListLable release];
    
    self.fristAlbumSmallImage = [[UIImageView alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5, 60, 20, 20)];
    [self.fristAlbumSmallImage setImage:[UIImage imageNamed:@"playcount1.png"]];
    [self.myView addSubview:self.fristAlbumSmallImage];
    self.fristAlbumSmallLable = [[UILabel alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5+20, 64, 30, 12)];
    self.fristAlbumSmallLable.font = [UIFont systemFontOfSize:12];
    self.fristAlbumSmallLable.font = [UIFont systemFontOfSize:13];
    [self.myView addSubview:self.fristAlbumSmallLable];
    [self.fristAlbumSmallImage release];
    
    self.secondAlbumSmallImage = [[UIImageView alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5 + 55, 60, 20, 20)];
    [self.secondAlbumSmallImage setImage:[UIImage imageNamed:@"likecount.png"]];
    [self.myView addSubview:self.secondAlbumSmallImage];
    [self.secondAlbumSmallImage release];
    self.secondAlbumSmallLable = [[UILabel alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5 + 75, 64, 30, 12)];
    self.secondAlbumSmallLable.font = [UIFont systemFontOfSize:12];
    [self.myView addSubview:self.secondAlbumSmallLable];
    [self.secondAlbumSmallLable release];
    
    
    self.thirdAlbumSmallImage = [[UIImageView alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5 + 110, 60, 20, 20)];
    [self.thirdAlbumSmallImage setImage:[UIImage imageNamed:@"commentcount.png"]];
    [self.myView addSubview:self.thirdAlbumSmallImage];
    [self.thirdAlbumSmallImage release];
    self.thirdAlbumSmallLable = [[UILabel alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/5 + 130, 64, 30, 12)];
    self.thirdAlbumSmallLable.font = [UIFont systemFontOfSize:12];
    [self.myView addSubview:self.thirdAlbumSmallLable];

    self.albumDownLoad = [[UIButton alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width*7/8, 50, 20, 20)];
    [self.myView addSubview:self.albumDownLoad];
    [self.thirdAlbumSmallLable release];
}

- (void)createAlbumView:(NovelAlbumListModel *)listModel{
    [self.albumListImageView sd_setImageWithURL:[NSURL URLWithString:listModel.coverSmall] placeholderImage:[UIImage imageNamed:@"1.jsp"]];
    
    self.albumListLable.text = listModel.title;
    
    self.albumFristListLable.text = [NSString stringWithFormat:@"by %@",listModel.nickname];
    
    self.fristAlbumSmallLable.text = [NSString stringWithFormat:@"%ld万",listModel.playtimes/10000];
    self.secondAlbumSmallLable.text = [NSString stringWithFormat:@"%ld",listModel.likes];
    self.thirdAlbumSmallLable.text = [NSString stringWithFormat:@"%ld",listModel.comments];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
